package com.zjz.demo.ForkJoin;

import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.Future;
import java.util.stream.LongStream;
import java.util.stream.Stream;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: zjz
 * @Date: 2021/10/09/14:41
 * @Description:
 * @Target: 求和计算
 */
public class ForkJoinDemo {


    private Long start;
    private Long end;

    private Long temp = 10000L;



//    ForkJoinPool   通过他来执行
//    ForkJoinTask


    public ForkJoinDemo(Long start,Long end){
        this.start=start;
        this.end = end;
    }


    public static void main(String[] args) {
//        Future
        long l = System.currentTimeMillis();

        long reduce = LongStream.rangeClosed(0L, 10_0000_0000L).parallel().reduce(0, Long::sum);

        long l1 = System.currentTimeMillis();

        System.out.println(reduce+ "时间:"+(l1-l));

    }


}
